package com.ideaaedi.zoo.example.springboot.seata.beta.service;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ideaaedi.zoo.example.springboot.seata.beta.entity.SysRolePO;
import com.ideaaedi.zoo.example.springboot.seata.beta.mapper.SysRoleMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRolePO> implements SysRoleService {
    
    @Override
    @Transactional(rollbackFor = Exception.class)
    public SysRolePO randomAddRole() {
        SysRolePO sysRole = new SysRolePO();
        sysRole.setId(IdWorker.getId());
        sysRole.setName(RandomStringUtils.random(10, true, true));
        save(sysRole);
        return sysRole;
    }
}
